/*
 * $Id: JMapContextMenu.java 24 2009-03-31 23:40:10Z aaron.day $
 */
package org.crazydays.gameplan.map.swing;


import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;

import org.crazydays.gameplan.Actions;
import org.crazydays.gameplan.GamePlan;
import org.crazydays.gameplan.map.swing.event.MapPropertiesAction;

/**
 * JMapContextMenu
 */
public class JMapContextMenu
        extends JPopupMenu
{
	/** serial version uid */
	public final static long serialVersionUID =
	        "$Id: JMapContextMenu.java 24 2009-03-31 23:40:10Z aaron.day $"
	                .hashCode();

	/** game plan */
	protected GamePlan gamePlan;

	/** map frame */
	protected JMapFrame mapFrame;

	/**
	 * JMapContextMenu constructor.
	 * 
	 * @param gamePlan GamePlan
	 * @param mapFrame MapFrame
	 */
	public JMapContextMenu(GamePlan gamePlan, JMapFrame mapFrame)
	{
		setGamePlan(gamePlan);
		setMapFrame(mapFrame);
		initialize();
	}

	/**
	 * Initialize map context menu.
	 */
	protected void initialize()
	{
		// display grid
		JMenuItem grid =
		        new JMenuItem(getGamePlan().getActions().get(
		                Actions.GRID_TOGGLE));
		add(grid);

		addSeparator();

		// add properties
		JMenuItem properties =
		        new JMenuItem(new MapPropertiesAction("Properties",
		                getMapFrame().getGameMap()));
		add(properties);
	}

	/**
	 * Set game plan.
	 * 
	 * @param gamePlan GamePlan
	 */
	public void setGamePlan(GamePlan gamePlan)
	{
		this.gamePlan = gamePlan;
	}

	/**
	 * Get game plan.
	 * 
	 * @return GamePlan
	 */
	public GamePlan getGamePlan()
	{
		return gamePlan;
	}

	/**
	 * Set map frame.
	 * 
	 * @param mapFrame Map frame
	 */
	public void setMapFrame(JMapFrame mapFrame)
	{
		this.mapFrame = mapFrame;
	}

	/**
	 * Get map frame.
	 * 
	 * @return Map frame
	 */
	public JMapFrame getMapFrame()
	{
		return mapFrame;
	}
}
